package com.epfresh.supplier.entity;

import com.epfresh.api.utils.DateUtil;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class PurchaseInfo {
    private String upstreamMerchant;
    private double quantity;
    private int productId;
    private String productSpecId;
    private long createdTime;

    private List<Object> originProveImageIdList;
    public List<Object> getOriginProveImageIdList() {
        return originProveImageIdList;
    }

    public void setOriginProveImageIdList(List<Object> originProveImageIdList) {
        this.originProveImageIdList = originProveImageIdList;
    }



    public long getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(long createdTime) {
        this.createdTime = createdTime;
    }

    public String getProductSpecId() {
        return productSpecId;
    }

    public void setProductSpecId(String productSpecId) {
        this.productSpecId = productSpecId;
    }

    private String origin;
    private String upstreamMarket;
    //
    private String originProveImageIds;
    private List<Images> originProveImages;
    //生产日期
    private String productionDate;
    //进场时间，预计送达时间
    private String arrivalDate;
    //预售截止时间
    private String saleDeadline;
    private String id;
    private String price;

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public List<Images> getOriginProveImages() {
        return originProveImages;
    }

    public void setOriginProveImages(List<Images> originProveImages) {
        this.originProveImages = originProveImages;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public List<Images> getImages() {
        return originProveImages ;
    }

    public void setImages(List<Images> images) {
        this.originProveImages = images;
    }

    public String getSaleDeadline() {
        if (saleDeadline != null ){
            saleDeadline = saleDeadline.replace("00:00:00","").trim();
        }
        return saleDeadline;
    }

    public void setSaleDeadline(String saleDeadline) {
        this.saleDeadline = saleDeadline;
    }

    public String getUpstreamMerchant() {
        return this.upstreamMerchant;
    }

    public void setUpstreamMerchant(String upstreamMerchant) {
        this.upstreamMerchant = upstreamMerchant;
    }

    public String getProductionDate() {
        if (productionDate != null ){
            productionDate = productionDate.replace("00:00:00","").trim();
        }
        return this.productionDate;
    }

    public void setProductionDate(String productionDate) {
        this.productionDate = productionDate;
    }


    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public int getProductId() {
        return this.productId;
    }

    public void setProductId(int productId) {
        this.productId = productId;
    }

    public String getOrigin() {
        return this.origin;
    }

    public void setOrigin(String origin) {
        this.origin = origin;
    }

    public String getUpstreamMarket() {
        return this.upstreamMarket;
    }

    public void setUpstreamMarket(String upstreamMarket) {
        this.upstreamMarket = upstreamMarket;
    }

    public String getOriginProveImageIds() {
        return this.originProveImageIds;
    }

    public void setOriginProveImageIds(String originProveImageIds) {
        this.originProveImageIds = originProveImageIds;
    }

    public String getArrivalDate() {
        if (arrivalDate != null ){
            arrivalDate = arrivalDate.replace("00:00:00","").trim();
        }
        return this.arrivalDate;
    }

    public boolean isPreDateLegal(){

        //预计送达时间

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            int c = DateUtil.compare(arrivalDate,saleDeadline);
            // -3,time1,time2都为空，1,time2大，-1,time1大，0,一样大 ，-2,异常
            if (c == -1 || c==0){
                Date date = new Date(System.currentTimeMillis());
                String format = sdf.format(date);

                c = DateUtil.compare(arrivalDate,format);
                if (c == -1 ){
                    return true;
                }
                return false;
            }else {
                return false;
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
    public boolean isDateLegal(){

        return false;
    }

    public void setArrivalDate(String arrivalDate) {
        this.arrivalDate = arrivalDate;
    }

    public boolean isQuantityEmpty() {
        return quantity == 0;
    }

    public double getQuantity() {
        return quantity;
    }

    public void setQuantity(double quantity) {
        this.quantity = quantity;
    }
}
